<template>
    <div>
     <h1 align="center">登录</h1>
     <table class="table table-bordered">
        <tbody class="bg-info">
            <tr>
                <td align="right">账号</td>
                <td>
                    <input type="text" v-model="info.UserName">
                </td>
            </tr>
            <tr>
                <td align="right">密码</td>
                <td>
                    <input type="password" v-model="info.UserPwd">
                </td>
            </tr>
            <tr>
                <td align="right"></td>
                <td>
                    <input type="button" value="登录" class="btn btn-primary" @click="ok">
                </td>
            </tr>
        </tbody>
     </table>
    </div>
</template>

<script setup lang="ts">
import { ref,reactive,onMounted } from "vue";
import axios from 'axios';
import moment from 'moment';
import {useRouter,useRoute} from 'vue-router';
const route=useRoute();
const router=useRouter();
import{useStore}from '@/stores/user';
const a=useStore();

let info:any=reactive({
    UserName:'',
    UserPwd:'',
})

const ok=()=>{
    axios({
        url:'https://localhost:7097/api/Login/Login',
        method:'get',
        params:info,
    })
    .then(res=>{
        console.log(res);
        if(res.data==-1){
            alert("账号不存在");
            return;
        }
        else if (res.data==-2) {
            alert("密码错误");
            return;
        }
        else{
            alert('登录成功');
            a.userinfo=res.data;

        }
    })
}

</script>

<style scoped>

</style>